Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate asset FT extensions with the DEX. #1029

Merged
merged 9 commits into from
Nov 26, 2024

Conversation

dzmitryhil
Copy link
Contributor

@dzmitryhil dzmitryhil commented Nov 21, 2024

Description

Integrate asset FT extensions with the DEX.

Reviewers checklist:

  • Try to write more meaningful comments with clear actions to be taken.
  • Nit-picking should be unblocking. Focus on core issues.

Authors checklist

  • Provide a concise and meaningful description
  • Review the code yourself first, before making the PR.
  • Annotate your PR in places that require explanation.
  • Think and try to split the PR to smaller PR if it is big.

This change is Reviewable

@dzmitryhil dzmitryhil requested a review from a team as a code owner November 21, 2024 11:15
@dzmitryhil dzmitryhil requested review from masihyeganeh, miladz68 and ysv and removed request for a team November 21, 2024 11:15
Copy link

codecov bot commented Nov 21, 2024

Codecov Report

Attention: Patch coverage is 77.67857% with 25 lines in your changes missing coverage. Please review.

Project coverage is 60.47%. Comparing base (cc533a6) to head (ef22d92).
Report is 19 commits behind head on master.

Files with missing lines Patch % Lines
x/asset/ft/keeper/keeper_dex.go 78.31% 12 Missing and 6 partials ⚠️
x/asset/ft/keeper/keeper.go 73.91% 4 Missing and 2 partials ⚠️
x/asset/ft/keeper/before_send.go 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1029      +/-   ##
==========================================
+ Coverage   52.48%   60.47%   +7.98%     
==========================================
  Files         141      159      +18     
  Lines       16262    18542    +2280     
==========================================
+ Hits         8535    11213    +2678     
+ Misses       6615     6231     -384     
+ Partials     1112     1098      -14     
Flag Coverage Δ
coreum 57.07% <77.67%> (?)
coreum-integration-tests-modules 46.38% <47.32%> (-6.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 16 files at r1, 4 of 6 files at r2, all commit messages.
Reviewable status: 5 of 16 files reviewed, 3 unresolved discussions (waiting on @dzmitryhil, @masihyeganeh, and @ysv)


a discussion (no related file):
you should run cargo fmt in the root of the project. some of the style changes that you editor has applied are not default rust style.


x/asset/ft/keeper/test-contracts/asset-extension/src/contract.rs line 282 at r2 (raw file):

    let bank_balance = query_bank_balance(deps, account, &token.denom)?;
    let whitelisted_balance = query_whitelisted_balance(deps, account, &token.denom)?;

we should account for expected to receieve when calculating whitelisting, to showcase how full integration looks likes.


x/asset/ft/keeper/keeper_dex.go line 105 at r2 (raw file):

	expectedToSpend, expectedToReceive sdk.Coin,
) error {
	if err := k.dexCheckExpectedToSpend(ctx, order, expectedToSpend, expectedToReceive); err != nil {

I might be a little confused, but I am not seeing where the whitelisting limits are enforced.

Copy link
Contributor Author

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 5 of 16 files reviewed, 3 unresolved discussions (waiting on @masihyeganeh, @miladz68, and @ysv)


a discussion (no related file):

Previously, miladz68 (milad) wrote…

you should run cargo fmt in the root of the project. some of the style changes that you editor has applied are not default rust style.

Done.


x/asset/ft/keeper/keeper_dex.go line 105 at r2 (raw file):

Previously, miladz68 (milad) wrote…

I might be a little confused, but I am not seeing where the whitelisting limits are enforced.

In dexCheckExpectedToReceive


x/asset/ft/keeper/test-contracts/asset-extension/src/contract.rs line 282 at r2 (raw file):

Previously, miladz68 (milad) wrote…

we should account for expected to receieve when calculating whitelisting, to showcase how full integration looks likes.

You can query it with the asset FT, Balance query.

Copy link
Contributor

@masihyeganeh masihyeganeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 8 of 16 files at r1, 6 of 6 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on @dzmitryhil, @miladz68, and @ysv)


x/asset/ft/keeper/keeper_dex_test.go line 1067 at r3 (raw file):

	testApp.MintAndSendCoin(t, ctx, acc, sdk.NewCoins(coinWithoutExtension))

	// the extension controls all features, bot to locked, amount

typo?


x/asset/ft/keeper/keeper_dex_test.go line 1119 at r3 (raw file):

	)

	coinWithExtensionProhibitedToReceive := sdk.NewCoin(extensionDenom, sdkmath.NewInt(104))

Please define these magic numbers as a constant just like integration-tests/modules/assetft_extension_test.go


x/asset/ft/keeper/keeper_dex.go line 407 at r3 (raw file):

	}

	if spendDef.IsFeatureEnabled(types.Feature_extension) {

Should we just check if extension is enabled? I believe it's better to change such conditions to check if they implemented that entry point (extension_place_order in this case). I'm not sure if we can check for that or not, but I believe it's the better implementation

Copy link
Contributor

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 7 of 16 files at r1, 2 of 6 files at r2, 2 of 2 files at r3, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @dzmitryhil and @ysv)


x/asset/ft/keeper/keeper_dex.go line 105 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

In dexCheckExpectedToReceive

I am not sure about whitelisting edge cases. let's discuss in a call.


x/asset/ft/keeper/test-contracts/asset-extension/src/contract.rs line 282 at r2 (raw file):

Previously, dzmitryhil (Dzmitry Hil) wrote…

You can query it with the asset FT, Balance query.

I mean that we should do this in our integration tests as a showcase.

Copy link
Contributor

@masihyeganeh masihyeganeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r4, all commit messages.
Reviewable status: all files reviewed, 5 unresolved discussions (waiting on @dzmitryhil and @ysv)

Copy link
Contributor Author

@dzmitryhil dzmitryhil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 4 unresolved discussions (waiting on @masihyeganeh, @miladz68, and @ysv)


x/asset/ft/keeper/keeper_dex.go line 105 at r2 (raw file):

Previously, miladz68 (milad) wrote…

I am not sure about whitelisting edge cases. let's discuss in a call.

OK


x/asset/ft/keeper/keeper_dex.go line 407 at r3 (raw file):

Previously, masihyeganeh (Masih Yeganeh) wrote…

Should we just check if extension is enabled? I believe it's better to change such conditions to check if they implemented that entry point (extension_place_order in this case). I'm not sure if we can check for that or not, but I believe it's the better implementation

They must be implemented if they want the FT with an extension to work with the DEX. That was the requirement we agreed on.


x/asset/ft/keeper/keeper_dex_test.go line 1067 at r3 (raw file):

Previously, masihyeganeh (Masih Yeganeh) wrote…

typo?

Done


x/asset/ft/keeper/keeper_dex_test.go line 1119 at r3 (raw file):

Previously, masihyeganeh (Masih Yeganeh) wrote…

Please define these magic numbers as a constant just like integration-tests/modules/assetft_extension_test.go

Agree, updated.


x/asset/ft/keeper/test-contracts/asset-extension/src/contract.rs line 282 at r2 (raw file):

Previously, miladz68 (milad) wrote…

I mean that we should do this in our integration tests as a showcase.

I don't think that this contract is a good example of how to use whitelisting.

Copy link
Contributor

@masihyeganeh masihyeganeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 4 of 4 files at r5, all commit messages.
Reviewable status: all files reviewed, 3 unresolved discussions (waiting on @miladz68 and @ysv)

masihyeganeh
masihyeganeh previously approved these changes Nov 25, 2024
Copy link
Contributor

@masihyeganeh masihyeganeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: all files reviewed, 2 unresolved discussions (waiting on @miladz68 and @ysv)

miladz68
miladz68 previously approved these changes Nov 25, 2024
Copy link
Contributor

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 of 1 files at r4, 4 of 4 files at r5, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

# Conflicts:
#	x/asset/ft/keeper/keeper.go
#	x/asset/ft/keeper/keeper_dex.go
#	x/dex/keeper/keeper_matching_fuzz_test.go
#	x/wbank/keeper/keeper.go
#	x/wbank/types/expected_keepers.go
@dzmitryhil dzmitryhil dismissed stale reviews from miladz68 and masihyeganeh via c7119b7 November 26, 2024 06:57
Copy link
Contributor

@masihyeganeh masihyeganeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 9 of 9 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

@dzmitryhil dzmitryhil requested a review from miladz68 November 26, 2024 09:52
Copy link
Contributor

@miladz68 miladz68 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 9 of 9 files at r6, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ysv)

@dzmitryhil dzmitryhil merged commit b5a4514 into master Nov 26, 2024
11 checks passed
@dzmitryhil dzmitryhil deleted the dzmitryhil/dex-extentions branch November 26, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants